home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-05-21 | 3.7 KB | 110 lines | [TEXT/ttxt] |
- in module DemoModule
-
- --*******************************************************************************
- --* Class name: Animation
- --*
- --* Inherits from: TwoDShape
- --* Class type: Concrete
- --* Component: Animation
- --*
- --* Description: This is a subclass of TwoDShape takes a series of bitmaps
- --* and flips through them at the given scale.
- --*
- --* Usage: an := new Animation series:<a series of bitmaps> \
- --* scale:8
- --*
- --* IVs: animationClock
- --* series
- --* cell
- --*
- --* Methods: start
- --* stop
- --* tick
- --* init
- --*
- --* Required files: none
- --*
- --* Notes:
- --*
- --* Author: Steve Mayer, Su Quek - Kaleida Labs, Inc.
- --*******************************************************************************
- class Animation (TwoDShape)
- instance variables
- animationClock
- series
- cell
- end
-
- --*=============================================================================*
- --* Method name: start
- --* Class: Animation
- --* Usage: start self
- --*-----------------------------------------------------------------------------*
- --* Description: Starts the animation clock.
- --* (i.e. starts flipping the bitmaps)
- --*=============================================================================*
- method start self {class Animation} ->
- (
- self.animationClock.rate := 1
- )
-
- --*=============================================================================*
- --* Method name: stop
- --* Class: Animation
- --* Usage: stop self
- --*-----------------------------------------------------------------------------*
- --* Description: Stops the animation clock.
- --* (i.e. stops flipping the bitmaps)
- --*=============================================================================*
- method stop self {class Animation} ->
- (
- self.animationClock.rate := 0
- )
-
- --*=============================================================================*
- --* Method name: tick
- --* Class: Animation
- --* Usage: tick self
- --*-----------------------------------------------------------------------------*
- --* Description: Change current cell to the next cell in the series.
- --* This method gets called at each tick of the animation clock.
- --*=============================================================================*
- method tick self {class Animation} clk ->
- (
- --*=========================================================================*
- --* Change to the appropriate cell
- --*=========================================================================*
- self.boundary := self.series[self.cell]
-
- --*=========================================================================*
- --* Get the next cell. Wrap around if at the end.
- --*=========================================================================*
- self.cell := ((mod self.cell self.series.size) as Integer) + 1
- )
-
- --*=============================================================================*
- --* Method name: init
- --* Class: Animation
- --* Usage: init self [series:<Array>] \
- --* [scale:<Number>]
- --*-----------------------------------------------------------------------------*
- --* Description: Sets up the callback to flip throught the series of bitmaps
- --*=============================================================================*
- method init self {class Animation} #rest args \
- #key series:(#(new Oval x2:100 y2:100)) \
- scale:(5) ->
- (
- apply nextMethod self boundary:(series[1]) fill:defaultBrush args
-
- self.series := series
- self.cell := 1
-
- local animationClock := (new Clock scale:scale)
- addPeriodicCallBack animationClock (clk -> tick self clk) animationClock #() 1
- animationClock.rate := 0
- self.animationClock := animationClock
- self
- )
-
-
-